<!--  -->
<template>
  <div class="layout">
    <div class="investment-box">
      <div
        style="display: flex; justify-content: space-between; margin-top: 20px"
      >
        <Breadcrumb
          class="breadcrumb"
          :crumbs="crumbs"
          style="margin-bottom: 20px"
        ></Breadcrumb>
        <!-- <div class="backBtn" @click="goBack()">返回列表</div> -->
      </div>
      <div class="building_Dynamics" v-loading="_loading">
        <div class="dynamics_Name">
          <ContainerTitle text="楼宇动态"></ContainerTitle>
          <div class="outerLayer">
            <div class="outerLayerName">实时掌握区内楼宇动态</div>
          </div>
          <div class="particulars">
            <div
              class="text_Introduction"
              v-for="(item, index) in particularsList"
              :key="index"
              @click="onJump(item)"
            >
              <div class="pictureCss">
                <!-- {{item.picture}} -->
                <!-- <img :src="item.picture==''?img:item.picture" /> -->
                <PublicImage
                  class="img"
                  v-if="item.logo == ''"
                  :src="require('@/assets/image/finance/product_dj.png')"
                ></PublicImage>
                <PublicImage class="img" v-else :src="item.logo"></PublicImage>
              </div>
              <div class="text_Description">
                <div class="nameCss">{{ item.title }}</div>
                <div class="contentCss">{{ item.subtitle }}</div>
                <div class="DateCss">
                  <div class="releaseDateCSS">
                    发布日期：
                    <span>{{ item.publishTime }}</span>
                  </div>
                  <div class="sourceCss ellipsis" style="max-width: 400px">
                    来源：
                    <span>{{ item.source }}</span>
                  </div>
                  <div class="ViewDetails">
                    <Buttons :buttons="buttons_toDetail" @none="''"></Buttons>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="notMore" v-if="particularsList.length == 0">
          暂时没有楼宇动态信息
        </div>
        <div
          class="notMore"
          v-if="
            Math.ceil(total / pageSize) <= pageNum &&
            particularsList.length != 0
          "
        >
          暂时没有更多楼宇动态
        </div>
        <div class="paging" v-if="particularsList.length != 0">
          <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNum"
            :page-sizes="[10, 20, 30, 50]"
            :page-size="pageSize"
            layout="total,  prev, pager, next, sizes, jumper"
            :total="total"
          ></el-pagination>
        </div>
      </div>
      <div class="ViewDetails">
        <Buttons :buttons="buttons" @goBack="back"></Buttons>
      </div>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
import Breadcrumb from "@/components/breadcrumb";
import { getDynamicsList } from "@/common/api/investment"
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {
    Breadcrumb,
  },
  data() {
    //这里存放数据
    return {
      buttons: [{ text: "返回", type: "normal", size: "l", method: "goBack" }],
      buttons_toDetail: [{ text: "查看详情", type: "success", size: "l", method: "none" }],
      _loading: false,
      img: "../../assets/image/finance/product_dj.png",
      pageNum: 1,
      pageSize: 10,
      total: null,
      crumbs: [
        {
          label: "招商中心",
          value: "investment",
        },
        { label: "楼宇动态列表", value: "", choose: true },
      ],
      particularsList: [], //楼宇动态列表数据
      publishTime: "", //发布时间
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    onJump(item) {
      this.$router.push({
        path: "/investment/investmenDynamictDetails",
        query: { id: item.id },
      });
    },
    back() {
      this.$router.replace("/investment");
    },
    handleSizeChange(e) {
      let that = this;
      that.pageSize = e;
      this.buildingDynamic();
    },
    handleCurrentChange(e) {
      let that = this;
      that.pageNum = e;
      this.buildingDynamic();
    },
    async buildingDynamic() {
      var data = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      };
      this._loading = true;
      let { code, msg, rows, total } = await getDynamicsList(data);
      this._loading = false;
      if (code != "200") return this.$message.warning(msg);
      this.particularsList = rows;
      this.total = total;
      this.particularsList.forEach((item, idnex) => {
        var date = new Date(item.publishTime);
        var N = date.getFullYear();
        var Y = date.getMonth() + 1;
        Y = Y < 10 ? "0" + Y : Y;
        var R = date.getDate();
        R = R < 10 ? "0" + R : R;
        item.publishTime = N + "年" + Y + "月" + R + "日";
      });
      
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this._loading = true;
    this.buildingDynamic();
    // this.$refs['foot'].init()
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
};
</script>
<style lang='scss' scoped>
.notMore {
  text-align: center;
  color: #ccc;
  padding: 10px;
}
.ViewDetails {
  height: 160px;
  display: flex;
  justify-content: center;
  .contactBuilding {
    width: 120px;
    height: 40px;
    background: #045db9;
    color: #fff;
    border-radius: 3px;
  }
  ._btn {
    width: 120px;
    height: 40px;
    background: #f1f2f4;
    color: #045db9;
    // text-align: center;
    // font-size: 14px;
    // border-radius: 3px;
    margin-bottom: 121px;
    // cursor: pointer;
    // line-height: 39px;
  }
}
//@import url(); 引入公共css类
.investment-box {
  width: 1200px;
  margin: 0 auto;
  .building_Dynamics {
    margin-top: 30px;
    min-height: 47vh;
    .dynamics_Name {
      .dynamic_building {
        display: flex;
        color: #045db9;
        font-size: 20px;
        font-weight: bold;
        font-family: Microsoft YaHei, Microsoft YaHei-Regular;
      }
      .outerLayer {
        width: 100%;
        height: 40px;
        display: flex;
        align-items: center;
        background-color: #f1f2f4;
        .outerLayerName {
          color: #333333;
          font-size: 14px;
          font-weight: 700;
          margin-left: 20px;
          font-family: Source Han Sans CN, Source Han Sans CN-Bold;
        }
      }
      .particulars {
        margin-top: 20px;
        .text_Introduction {
          display: flex;
          border: 1px solid #eeeeee;
          padding: 20px;
          margin-bottom: 20px;
          justify-content: space-between;
          .pictureCss {
            width: 314px;
            height: 200px;
            // border: 1px solid red;
            .img {
              width: 312px;
              height: 198px;
              object-fit: cover;
            }
          }
          .text_Description {
            width: 70%;

            .nameCss {
              color: #333333;
              font-size: 24px;
              font-weight: bold;
              color: #333333;
              font-family: Source Han Sans CN, Source Han Sans CN-Bold;
              margin-bottom: 20px;
              display: flex;
              text-align: left;
              white-space: normal;
              word-break: break-all;
            }
            .contentCss {
              font-size: 12px;
              color: #595e64;
              text-align: left;
              line-height: 24px;
              height: 105px;
              font-family: Microsoft YaHei, Microsoft YaHei-Regular;
              text-align: left;
              white-space: normal;
              word-break: break-all;
            }
            .DateCss {
              display: flex;
              align-items: flex-end;
              justify-content: space-between;
              color: #999999;
              font-size: 14px;
              font-family: Microsoft YaHei, Microsoft YaHei-Regular;
              .releaseDateCSS {
                span {
                  color: #333333;
                }
              }
              .sourceCss {
                span {
                  color: #333333;
                }
              }
              .ViewDetails {
                display: flex;
                align-items: flex-end;
                .contactBuilding {
                  background-color: #045db9;
                  color: #ffff;
                }
              }
            }
          }
        }
      }
    }
  }
  .paging {
    display: flex;
    justify-content: flex-end;
    line-height: 100px;
  }
}
::v-deep .el-divider--horizontal {
  background: #045db9;
  margin: 15px 0;
  height: 2px;
}
</style>